<?php

class MainController  {
	
	private static $generatedContent;
	
	public static function getMainWindow ()  {
		
		$data = MainModel::getMainMenuData();
		MainView::mainMenu($data);
		$data = MainModel::getMainMenuControlData();
		MainView::mainMenuControl($data);
		if (empty($_GET['function']))  {
			MainView::subMenuFrame();
			MainView::textContentFrame(MainModel::getMainTextContent());
		}
		else  {
			FunctionTranslator::translateToController($_GET['function']);
		}
		
		MainView::errorMessageArea(MainModel::getErrorMessageData());

		
	}
	
	public static function setGeneratedContent ($content, $placeHolder)  {
		
		if (self::$generatedContent == null)  {
			self::$generatedContent = AutoFileLoader::getFileContent(AutoFileLoader::FILE_HTML, 'kirche-um-6-admin');
		}
		
		self::$generatedContent = Replacer::replacePlaceholder(self::getGeneratedContent(), $content, $placeHolder);
	
	}
	
	public static function getGeneratedContent ()  {
		return self::$generatedContent;
	}
	
	public static function getSessionData ($key)  {
		$session = $GLOBALS['TSFE']->fe_user->getKey('ses', 'tx_ttadminpanel');
		return $session[$key];
	}
	
	public static function storeSessionData ($data)  {
		$GLOBALS['TSFE']->fe_user->setKey('ses', 'tx_ttadminpanel', $data); 
		$GLOBALS['TSFE']->fe_user->storeSessionData();
	}
	
	public static function getRequestUri ()  {
		return $_SERVER['REQUEST_URI'];
	}

	public static function toString ()  {
		return self::getGeneratedContent();
	}
	
}

?>